package com.sos.widget.view.recyclerview

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * @Description 折叠图标
 * @Author 梁浩文
 * @Date 2023/5/10 16:05
 */
class FoldDecoration(val foldMargin: Int) : RecyclerView.ItemDecoration() {
    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State,
    ) {
        super.getItemOffsets(outRect, view, parent, state)
        val layoutManager = parent.layoutManager
        val position = parent.getChildAdapterPosition(view)
        val childCount = parent.getChildCount()
        outRect.top = 0
        outRect.left = if (position != 0) foldMargin else 0
        outRect.right = 0
        outRect.bottom = 0

    }
}